home *** CD-ROM | disk | FTP | other *** search
- OMP_THREADS(3) Last changed: 2-24-98
-
-
- NNAAMMEE
- oommpp__sseett__nnuumm__tthhrreeaaddss, oommpp__ggeett__nnuumm__tthhrreeaaddss, oommpp__ggeett__mmaaxx__tthhrreeaaddss,
- oommpp__ggeett__tthhrreeaadd__nnuumm, oommpp__ggeett__nnuumm__pprrooccss, oommpp__sseett__ddyynnaammiicc,
- oommpp__ggeett))ddyynnaammiicc, oommpp__iinn__ppaarraalllleell, OOMMPP__SSEETT__NNUUMM__TTHHRREEAADDSS,
- OOMMPP__GGEETT__NNUUMM__TTHHRREEAADDSS, OOMMPP__GGEETT__MMAAXX__TTHHRREEAADDSS, OOMMPP__GGEETT__TTHHRREEAADD__NNUUMM,
- OOMMPP__GGEETT__NNUUMM__PPRROOCCSS, OOMMPP__SSEETT__DDYYNNAAMMIICC, OOMMPP__GGEETT__DDYYNNAAMMIICC, OOMMPP__IINN__PPAARRAALLLLEELL -
- Runtime library procedures used to set, call or return numbers of
- threads
-
- SSYYNNOOPPSSIISS
- C/C++: (Deferred implementation)
- ##iinncclluuddee <<oommpp__sseett__nnuumm__tthhrreeaaddss>>
- vvooiidd oommpp__sseett__nnuumm__tthhrreeaaddss ((_i_n_t_e_g_e_r-_e_x_p_r_e_s_s_i_o_n))
-
- ##iinncclluuddee <<oommpp__ggeett__nnuumm__tthhrreeaaddss>>
- iinntt oommpp__ggeett__nnuumm__tthhrreeaaddss(())
-
- ##iinncclluuddee <<oommpp__ggeett__mmaaxx__tthhrreeaaddss>>
- iinntt oommpp__ggeett__mmaaxx__tthhrreeaaddss(())
-
- ##iinncclluuddee <<oommpp__ggeett__tthhrreeaadd__nnuumm>>
- iinntt oommpp__ggeett__tthhrreeaadd__nnuumm(())
-
- ##iinncclluuddee <<oommpp__ggeett__nnuumm__pprrooccss>>
- iinntt oommpp__ggeett__nnuumm__pprrooccss(())
-
- ##iinntteeggeerr <<oommpp__sseett__ddyynnaammiicc>>
- vvooiidd oommpp__sseett__ddyynnaammiicc((_i_n_t_e_g_e_r-_e_x_p_r_e_s_s_i_o_n))
-
- ##iinntteeggeerr <<oommpp__ggeett__ddyynnaammiicc>>
- iinntt oommpp__ggeett__ddyynnaammiicc(())
-
- ##iinntteeggeerr <<oommpp__iinn__ppaarraalllleell>>
- vvooiidd oommpp__iinn__ppaarraalllleell(())
-
- Fortran:
- CCAALLLL OOMMPP__SSEETT__NNUUMM__TTHHRREEAADDSS ((_i_n_t_e_g_e_r-_e_p_x_r_e_s_s_i_o_n))
-
- IINNTTEEGGEERR OOMMPP__GGEETT__NNUUMM__TTHHRREEAADDSS(())
-
- IINNTTEEGGEERR OOMMPP__GGEETT__MMAAXX__TTHHRREEAADDSS(())
-
- IINNTTEEGGEERR OOMMPP__GGEETT__TTHHRREEAADD__NNUUMM(())
-
- IINNTTEEGGEERR OOMMPP__GGEETT__NNUUMM__PPRROOCCSS(())
-
- CCAALLLL OOMMPP__SSEETT__DDYYNNAAMMIICC((_l_o_g_i_c_a_l-_e_x_p_r_e_s_s_i_o_n))
-
- LLOOGGIICCAALL OOMMPP__GGEETT__DDYYNNAAMMIICC(())
-
- LLOOGGIICCAALL OOMMPP__IINN__PPAARRAALLLLEELL(())
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- IRIX systems
-
- SSTTAANNDDAARRDDSS
- OpenMP Fortran API
-
- DDEESSCCRRIIPPTTIIOONN
- The following descriptions contain information for Fortran and C/C++.
-
- oommpp__sseett__nnuumm__tthhrreeaaddss, OOMMPP__SSEETT__NNUUMM__TTHHRREEAADDSS
- This procedure sets the number of threads to use in a team.
-
- The _i_n_t_e_g_e_r-_e_x_p_r_e_s_s_i_o_n is evaluated, and its value is used as the
- number of threads to use beginning with the next non-nested parallel
- region.
-
- This call takes precedence over the OOMMPP__NNUUMM__TTHHRREEAADDSS environment
- varable. When dynamic threads is enabled, this value is interpreted
- to be the maximum number of threads to use.
-
- oommpp__ggeett__nnuumm__tthhrreeaaddss, OOMMPP__GGEETT__NNUUMM__TTHHRREEAADDSS
- This function returns the number of threads currently in the team
- executing the parallel region from which it is called.
- Mechanisms that control the number of threads include the runtime
- system when dynamic adjustment of the number of threads is
- enabled, the oommpp__sseett__nnuumm__tthhrreeaaddss(()) call (OOMMPP__SSEETT__NNUUMM__TTHHRREEAADDSS
- call), and the OOMMPP__NNUUMM__TTHHRREEAADDSS environment variable. The default
- number of threads is implementation dependent in the case that
- the number of threads has not been specified by the user.
-
- This function binds to the closest enclosing ppaarraalllleell (PPAARRAALLLLEELL)
- directive. When called from a nested parallel region that is
- serialized, this function returns 1.
-
- oommpp__ggeett__mmaaxx__tthhrreeaaddss, OOMMPP__GGEETT__MMAAXX__TTHHRREEAADDSS
- This function returns the maximum value that calls to
- oommpp__ggeett__nnuumm__tthhrreeaaddss (OOMMPP__GGEETT__NNUUMM__TTHHRREEAADDSS) may return. If
- oommpp__sseett__nnuumm__tthhrreeaaddss (OOMMPP__SSEETT__NNUUMM__TTHHRREEAADDSS) is called with a larger
- value, subsequent calls o this function will return the larger
- value. This function may be used to allocate maximal sized per-
- thread data structures when oommpp__sseett__ddyynnaammiicc (OOMMPP__SSEETT__DDYYNNAAMMIICC) is
- set to nnoonn--zzeerroo (TTRRUUEE). This function has global scope and
- returns the maximum value whether executing from a serial region
- or a parallel region.
-
- oommpp__ggeett__tthhrreeaadd__nnuumm, OOMMPP__GGEETT__TTHHRREEAADD__NNUUMM
- This function returns the thread number within the team. The
- master thread of the team is thread 0. The thread number is
- between 0 and oommpp__ggeett__nnuumm__tthhrreeaaddss(())-1 (OOMMPP__GGEETT__NNUUMM__TTHHRREEAADDSS(())-1)
- inclusive. This function binds to the closest enclosing ppaarraalllleell
- (PPAARRAALLLLEELL) directive. If called from a serial region, it returns
- 0. If called from within a nested parallel region that is
- serialized, this function returns 0.
-
- oommpp__ggeett__nnuumm__pprrooccss, OOMMPP__GGEETT__NNUUMM__PPRROOCCSS
- This function returns the number of processors that are available
- to the program.
-
- oommpp__sseett__ddyynnaammiicc, OOMMPP__SSEETT__DDYYNNAAMMIICC
- This function enables or disables dynamic adjustment of the
- number of threads available for execution of parallel regions.
-
- If _i_n_t_e_g_e_r-_e_x_p_r_e_s_s_i_o_n (_l_o_g_i_c_a_l-_e_x_p_r_e_s_s_i_o_n) _e_v_a_l_u_a_t_e_s _t_o nnoonn--zzeerroo
- (TTRRUUEE), the number of threads that are used for executing
- subsequent parallel regions may be adjusted automatically by the
- runtime environment to best utilize system resources. As a
- consequece, the number of threads specified by the user may
- actually be interpreted as a maximum thread count. The number of
- threads always remains fixed over the duration of each parallel
- region and is reported by oommpp__ggeett__nnuumm__tthhrreeaaddss(())
- (OOMMPP__GGEETT__NNUUMM__TTHHRREEAADDSS). If _i_n_t_e_g_e_r-_e_x_p_r_e_s_s_i_o_n (_l_o_g_i_c_a_l-
- _e_x_p_r_e_s_s_i_o_n) evaluates to zzeerroo (FFAALLSSEE), dynamic adjustment is
- disabled.
-
- A call to oommpp__sseett__ddyynnaammiicc (OOMMPP__SSEETT__DDYYNNAAMMIICC) has precedence over
- the OOMMPP__DDYYNNAAMMIICC environment variable. The default for the
- dynamic adjustment of threads is implementation dependent. As a
- result, user codes that depend on a specific number of threads
- for correct execution should explicitly disable dynamic threads.
- Implementations are not required to provide the ability to
- dynamically adjust the number of threads, but they are required
- to provide the interface to support portability across all
- platforms.
-
- oommpp__ggeett__ddyynnaammiicc, OOMMPP__GGEETT__DDYYNNAAMMIICC
- This function returns nnoonn--zzeerroo (TTRRUUEE) if dynamic adjustment of
- the number of threads is enabled; otherwise, it returns zzeerroo
- (FFAALLSSEE).
-
- oommpp__iinn__ppaarraalllleell, OOMMPP__IINN__PPAARRAALLLLEELL
- This function returns nnoonn--zzeerroo (TTRRUUEE) if it is within the dynamic
- extent of a parallel region that actually went parallel;
- otherwise, it returns zzeerroo (FFAALLSSEE). This function can be used to
- determine whether it was called from within a parallel region.
- It has global scope and will return TTRRUUEE from within a nested
- parallel region.
-
- EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
- OOMMPP__SSCCHHEEDDUULLEE
- This variable applies only to DDOO and PPAARRAALLLLEELL DDOO directives that
- have the schedule type RRUUNNTTIIMMEE. The schedule type and chunk size
- for all such loops can be set at runtime by setting this
- environment variable to any of the recognized schedule types and
- to an optional chunk size. For DDOO and PPAARRAALLLLEELL DDOO directives
- that have a schedule type other than RRUUNNTTIIMMEE, this environment
- variable is ignored. The default value for this environment
- variable is implementation dependent. If the optional chunk size
- is not set, a chunk size of 1 is assumed, except in the case of a
- SSTTAATTIICC schedule, the chunk size is set to the loop iteration
- space divided by the number of threads applied to the loop.
-
- OOMMPP__NNUUMM__TTHHRREEAADDSS
- This variable sets the number of threads to use during execution,
- unless that number is explicitly changed by calling
- oommpp__sseett__nnuumm__tthhrreeaaddss(()). When dynamic adjustment of the number of
- threads is enalbed, the value of this environment variable may be
- interpreted as the maximum number of threads to use. The default
- value is implementation dependent.
-
- OOMMPP__DDYYNNAAMMIICC
- This variable enables or disables dynamic adjustment of the
- number of threads available for execution of parallel regions.
- If set to TTRRUUEE, the number of threads that are used for executing
- parallel regions may be adjusted by the runtime environment to
- best utilize system resources.
-
- If set to FFAALLSSEE, dynamic adjustment is disabled. The default
- condition is implementation dependent.
-
- OOMMPP__NNEESSTTEEDD
- This variable enables or disables nested parallelism. If set to
- TTRRUUEE, nested parallelism is enabled; if it is set to FFAALLSSEE, it is
- disabled. The default value is FFAALLSSEE.
-
- EEXXAAMMPPLLEESS
- Example 1.
-
- rreevviieewweerrss -- tthhee ffoolllloowwiinngg ppaarraaggrraapphh ccoonnttaaiinnss ssoommee ""iimmpplleemmeennttaattiioonn--
- ddeeppeennddeenntt"" wwoorrddiinngg ffrroomm tthhee OOppeennMMPP ssttaannddaarrdd.. hhooww sshhoouulldd tthhiiss
- ppaarraaggrraapphh bbee mmooddiiffiieedd ffoorr SSGGII//CCrraayy''ss iimmpplleemmeennttaattiioonn ooff OOppeennMMPP??
-
- Some programs rely on a fixed, prespecified number of threads to
- execute correctly. Because the default setting for the dynamic
- adjustment of the number of threads is implementation-dependent, such
- programs can choose to turn off the dynamic threads capability and set
- the number of threads explicitly. This ensures portability. The
- following Fortran 90 code fragment specifies a fixed number of
- threads:
-
- CALL OMP_SET_DYNAMIC(.FALSE.)
- CALL OMP_SET_NUM_THREADS(16)
- !$OMP PARALLEL DEFAULT(PRIVATE)SHARED(X,NPOINTS)
- IAM = OMP_GET_THREAD_NUM()
- IPOINTS = NPOINTS/16
- CALL DO_BY_16(X,IAM,IPOINTS)
- !$OMP END PARALLEL
-
- In the preceding code fragment, the code executes correctly only if it
- is executed by 16 threads. Note that the number of threads executing
- a parallel region remains constant during a parallel region,
- regardless of the dynamic threads setting. The dynamic threads
- mechanism determines the number of threads to use at the start of the
- parallel region and keeps it constant for the duration of the region.
-
- Example 2. Consider the following incorrect Fortran 90 code:
-
- NP = OMP_GET_NUM_THREADS()
- !$OMP PARALLEL DO SCHEDULE(STATIC)
- DO I = 0, NP-1
- CALL WORK(I)
- ENDDO
- !$OMP END PARALLEL DO
-
- The OOMMPP__GGEETT__NNUUMM__TTHHRREEAADDSS(()) call returns 1 in the serial section of the
- code, so NNPP will always be equal to 1.
-
- To determine the number of threads that will be deployed for the
- parallel region, the call should be inside the parallel region. The
- following code is a rewrite of the preceding code. It shows how to
- rewrite the program without including a query for the number of
- threads:
-
- !$OMP PARALLEL PRIVATE(I)
- I = OMP_GET_THREAD_NUM()
- CALL WORK(I)
- !$OMP END PARALLEL
-
- SSEEEE AALLSSOO
- oommpp__lloocckk(3) for information on how to manipulate locks
-
- oommpp__nneesstteedd(3) to manipulate or report status of nested parallelism
-
- This man page is available only online.
-